﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace JqueryNet.FormControl.FormWebControl
{
    public class JButton : JWebControl
    {
        Button button;
        public JButton(Button button)
            : base(button)
        {
            this.button = button;
        }

        public override void Attr(string key)
        {
            switch (key.ToLower())
            {
                case "css":
                case "class":
                case "cssclass":
                    Value = button.CssClass;
                    return;
                case "height":
                    Value = button.Height;
                    return;
                case "width":
                    Value = button.Width;
                    return;
                case "text":
                case "value":
                    Value = button.Text;
                    return;
                default:
                    base.Attr(key); return;
            }
        }

        public override void Attr(string key, string value)
        {
            int b;
            int.TryParse(value, out b);
            switch (key.ToLower())
            {
                case "css":
                case "class":
                case "cssclass":
                    Value = button.CssClass;
                    return;
                case "height":
                    button.Height = b;
                    return;
                case "width":
                    button.Width = b;
                    return;
                case "text":
                case "value":
                    button.Text = value;
                    return;
                default:
                    base.Attr(key, value); return;
            }
        }

        public override void Val()
        {
            Value = button.Text;
        }

        public override void Val(string value)
        {
            button.Text = value;
        }
    }
}
